package com.gzck.gzck_verson2.controller;


import com.gzck.gzck_verson2.pojo.GSensorExcitetInfo;
import com.gzck.gzck_verson2.service.IGSensorExcitetInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 传感器激励类型库 前端控制器
 * </p>
 *
 * @author 任永辉
 * @since 2024-01-27
 */
@RestController
@RequestMapping("/g-sensor-excitet-info")
public class GSensorExcitetInfoController {

    @Autowired
    private IGSensorExcitetInfoService sensorExcitetInfoService;

    // 添加传感器和激励器信息
    @PostMapping("/add")
    public boolean addSensorExcitetInfo(@RequestBody GSensorExcitetInfo sensorExcitetInfo) {
        return sensorExcitetInfoService.save(sensorExcitetInfo);
    }

    // 删除传感器和激励器信息
    @DeleteMapping("/delete/{id}")
    public boolean deleteSensorExcitetInfo(@PathVariable Long id) {
        return sensorExcitetInfoService.removeById(id);
    }

    // 更新传感器和激励器信息
    @PutMapping("/update")
    public boolean updateSensorExcitetInfo(@RequestBody GSensorExcitetInfo sensorExcitetInfo) {
        return sensorExcitetInfoService.updateById(sensorExcitetInfo);
    }

    // 查询单个传感器和激励器信息
    @GetMapping("/{id}")
    public GSensorExcitetInfo getSensorExcitetInfo(@PathVariable Long id) {
        return sensorExcitetInfoService.getById(id);
    }

    // 查询所有传感器和激励器信息
    @GetMapping("/all")
    public List<GSensorExcitetInfo> getAllSensorExcitetInfos() {
        return sensorExcitetInfoService.list();
    }
}
